/* SPDX-License-Identifier: GPL-2.0-or-later
 *
 * Copyright (C) 2016-2018, LomboTech Co.Ltd.
 * Authors:
 *	lomboswer <lomboswer@lombotech.com>
 *
 * This program is free software; you can redistribute  it and/or modify it
 * under  the terms of  the GNU General  Public License as published by the
 * Free Software Foundation;  either version 2 of the  License, or (at your
 * option) any later version.
 */

#ifndef _LOMBO_DC_H_
#define _LOMBO_DC_H_

struct drm_plane;
struct lombo_crtc;
struct lombo_dc;
struct lombo_tcon;
struct drm_lombo_rect_wh;

#ifdef CONFIG_DRM_LOMBO_DC

/* atomic apis */
int lombo_dc_get_csfmt(struct lombo_dc *dc);
int lombo_dc_get_scn(struct lombo_dc *dc, int *width, int *height);
int lombo_dc_atomic_check(struct lombo_dc *dc,
	struct drm_crtc_state *state);
void lombo_dc_mode_set_nofb(struct lombo_dc *dc,
	struct drm_display_mode *mode);
void lombo_dc_atomic_enable(struct lombo_dc *dc);
void lombo_dc_atomic_disable(struct lombo_dc *dc);
void lombo_dc_color_pre_commit(struct lombo_dc *dc);

/* called by irq handler */
int lombo_dc_commit(struct lombo_dc *dc);

/* apis for initial */
struct lombo_dc *lombo_find_dc_by_id(int id);
void lombo_dc_set_crtc_tcon(struct lombo_dc *dc,
	struct lombo_crtc *ecrtc, struct lombo_tcon *tcon);
struct drm_plane **lombo_dc_planes_init(struct lombo_dc *dc);
int lombo_dc_probe_fbdev(struct lombo_dc *dc, struct drm_fb_helper *fb_helper);

int lombo_dc_kms_show(struct lombo_dc *dc,
	struct seq_file *m, void *data);

int lombo_dc_set_fb_transparent_rect(struct lombo_dc *dc,
	struct drm_framebuffer *fb, struct drm_lombo_rect_wh *rect);
int lombo_dc_get_fb_transparent_rect(struct lombo_dc *dc,
	struct drm_framebuffer *fb, struct drm_lombo_rect_wh *rect);

int lombo_dc_get_color_status(struct lombo_dc *dc, int type);
int lombo_dc_set_color_status(struct lombo_dc *dc, int type, int value);

#else /* !CONFIG_DRM_LOMBO_DC */

static inline int lombo_dc_get_csfmt(struct lombo_dc *dc)
{
	return -ENODEV;
}

static inline int lombo_dc_get_scn(struct lombo_dc *dc,
	int *width, int *height)
{
	return -ENODEV;
}

/* atomic apis */
static inline int lombo_dc_atomic_check(struct lombo_dc *dc,
	struct drm_crtc_state *state)
{
	return -ENODEV;
}

static inline void lombo_dc_mode_set_nofb(struct lombo_dc *dc,
	struct drm_display_mode *mode)
{
}

static inline void lombo_dc_atomic_enable(struct lombo_dc *dc)
{
}

static inline void lombo_dc_atomic_disable(struct lombo_dc *dc)
{
}

static inline void lombo_dc_color_pre_commit(struct lombo_dc *dc)
{
}

static inline int lombo_dc_commit(struct lombo_dc *dc)
{
	return -ENODEV;
}

static inline struct lombo_dc *lombo_find_dc_by_id(int id)
{
	return NULL;
}

static inline void lombo_dc_set_crtc_tcon(struct lombo_dc *dc,
	struct lombo_crtc *ecrtc, struct lombo_tcon *tcon)
{
}

static inline struct drm_plane **lombo_dc_planes_init(struct lombo_dc *dc)
{
	static struct drm_plane *null_plane[1] = { NULL };

	return &(null_plane[0]);
}

static inline int lombo_dc_probe_fbdev(struct lombo_dc *dc,
	struct drm_fb_helper *fb_helper)
{
	return -ENODEV;
}


static inline int lombo_dc_kms_show(struct lombo_dc *dc,
	struct seq_file *m, void *data)
{
	return -ENODEV;
}

static inline int lombo_dc_set_fb_transparent_rect(struct lombo_dc *dc,
	struct drm_framebuffer *fb, struct drm_lombo_rect_wh *rect)
{
	return -ENODEV;
}

static inline int lombo_dc_get_fb_transparent_rect(struct lombo_dc *dc,
	struct drm_framebuffer *fb, struct drm_lombo_rect_wh *rect)
{
	return -ENODEV;
}

static inline int lombo_dc_get_color_status(struct lombo_dc *dc, int type)
{
	return -ENODEV;
}
static inline int lombo_dc_set_color_status(struct lombo_dc *dc,
							int type, int value)
{
	return -ENODEV;
}

#endif /* CONFIG_DRM_LOMBO_DC */

#endif /* #ifndef _LOMBO_DC_H_ */
